package com.spa.domain.service;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.spa.domain.entity.DouYinComment;
import com.spa.infrastructure.mapper.DouYinCommentMapperStruct;
import com.spa.infrastructure.repository.condition.DouYinCommentCondition;
import com.spa.infrastructure.repository.service.DouYinCommentRepositoryService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class DouYinCommentService {

    @Resource
    private DouYinCommentRepositoryService douYinCommentRepositoryService;

    /**
     * 查询一级评论
     * @param current
     * @param size
     * @param itemId
     * @return
     */
    public Page<DouYinComment> page(long current, long size, String itemId) {
        DouYinCommentCondition condition = new DouYinCommentCondition();
        condition.setCurrent(current);
        condition.setSize(size);
        condition.setItemId(itemId);
        condition.setParentId(itemId);
        return DouYinCommentMapperStruct.INSTANCE.po2Entity4Page(douYinCommentRepositoryService.page(condition));
    }

    /**
     * 查询二级级评论
     * @param current
     * @param size
     * @param itemId
     * @return
     */
    public Page<DouYinComment> page(long current, long size, String itemId, String parentId) {
        DouYinCommentCondition condition = new DouYinCommentCondition();
        condition.setCurrent(current);
        condition.setSize(size);
        condition.setItemId(itemId);
        condition.setParentId(parentId);
        return DouYinCommentMapperStruct.INSTANCE.po2Entity4Page(douYinCommentRepositoryService.page(condition));
    }

}
